//
//  Ext + UIImageView.swift
//  SinaProjectTest
//
//  Created by zhanghaifeng on 16/10/23.
//  Copyright © 2016年 BBSWaitting. All rights reserved.
//

import UIKit

extension UIImageView{
    
    
    /// 快捷创建UIImageView
    ///
    /// - parameter imgNamed: 图片名称
    ///
    /// - returns: 
    convenience init(imgNamed: String) {
        self.init(image: UIImage(named: imgNamed))
    }
    
    func xl_setImage(withUrlString: String?, placeholderImgName: String?){
        // 获取图片的 url
        let url = URL(string: withUrlString ?? "")
        // 判断他是否为 nil
        guard let u = url else {
            return
        }
        // 调用 sdWebImage 的方法
        self.sd_setImage(with: u, placeholderImage: UIImage(named: placeholderImgName ?? ""))
    }
}
